﻿using Newtonsoft.Json;
using System;

namespace BlueportCoffee.http
{
    public class HttpMsg
    {
        private static HttpMsg instance;
        private HttpMsg() { }

        public static HttpMsg Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new HttpMsg();
                }
                return instance;
            }
        }
        /// <summary>
        /// 保存物料和设备状态
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string saveDeviceMatterMsg(string data)
        {
            try
            {
                var Matter = BaseService.Instance.HttpPostRaw("notify/v1/alter", data);
                return Matter;
            }
            catch (Exception)
            {
                return "";
            }
        }
        /// <summary>
        /// 所有排队订单信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string deviceOrderQueueListMsg()
        {
            try
            {
                GetOrderModel device = new GetOrderModel();
                string lists = JsonConvert.SerializeObject(device);
                var QueueList = BaseService.Instance.HttpPostRaw("order/v1/getOrder", lists, true);
                return QueueList;
            }
            catch (Exception)
            {
                return "";
            }
        }
        /// <summary>
        /// 心跳信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string HeartCheckListMsg()
        {
            try
            {
                HeartCheck device = new HeartCheck();
                string lists = JsonConvert.SerializeObject(device);
                var QueueList = BaseService.Instance.HttpPostRaw("order/v1/heartCheck", lists, true);
                return QueueList;
            }
            catch (Exception)
            {
                return "";
            }
        }
        /// <summary>
        /// 修改订单状态
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string editDeviceOrderStatusMsg(string data)
        {
            try
            {
                var editDevice = BaseService.Instance.HttpPostRaw("notify/v1/updateOrderStatus", data);
                return editDevice;
            }
            catch (Exception)
            {
                return "";
            }
        }
        /// <summary>
        /// 扫码排队
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string orderQueueMsg(string data)
        {
            try
            {
                var Queue = BaseService.Instance.HttpPostRaw("orderQueue", data);
                return Queue;
            }
            catch (Exception)
            {
                return "";
            }
        }
    }
    public class HTTPMsg
    {
        public string code { get; set; }
        public string msg { get; set; }
        public object data { get; set; }
    }
}
